<template>
  <div>
    <a-row :gutter="[16, 16]">
      <a-col span="8">
        <a-card
          style="background-color: rgb(247, 247, 247)"
          title="空调亚健康阈值设置"
          :bordered="false"
        >
          <p style="text-align: right">
            <a-button type="primary" icon="edit" size="small" @click="handleSet('air')">设置</a-button>
          </p>
        </a-card>
      </a-col>
      <a-col span="8">
        <a-card
          style="background-color: rgb(247, 247, 247)"
          title="数据中心亚健康阈值设置"
          :bordered="false"
        >
          <p style="text-align: right">
            <a-button type="primary" icon="edit" size="small" @click="handleSet('datacenter')">
              设置
            </a-button>
          </p>
        </a-card>
      </a-col>
      <a-col span="8">
        <a-card
          style="background-color: rgb(247, 247, 247)"
          title="UPS亚健康阈值设置"
          :bordered="false"
        >
          <p style="text-align: right">
            <a-button type="primary" icon="edit" size="small" @click="handleSet('ups')">设置</a-button>
          </p>
        </a-card>
      </a-col>
    </a-row>
    <set-threshold-modal ref="setThresholdModal"></set-threshold-modal>
  </div>
</template>

<script>
import { GwListMixin } from "@/mixins/GwListMixin";
import { gPostAction } from "@/api/manage";
import SetThresholdModal from "./modules/SetThresholdModal";

export default {
  name: "Thresholds",
  mixins: [GwListMixin],
  components: {
    SetThresholdModal,
  },
  data() {
    return {
      deviceType: "air",
    };
  },
  mounted() {
    this.loadDatacenterList();
    // this.loadData();
  },
  methods: {
    // loadData() {
    //   if (this.deviceType === "air") {
    //     this.columns = this.airColumns;
    //   } else if (this.deviceType === "ups") {
    //     this.columns = this.upsColumns;
    //   } else {
    //     this.columns = this.datacenterColumns;
    //   }
    //   gPostAction(this.url[this.deviceType + "List"], {}).then((res) => {
    //     const data = res.data;
    //     if (data && data.list) {
    //       this.gDataSource = data.list;
    //       this.gPagination.total = data.totalCount;
    //     }
    //   });
    // },
    loadDatacenterList() {
      let postData = {
        title: "健康智能监控-数据中心设备亚健康分析与预警-亚健康阈值设置",
        content: "查看亚健康阈值设置页面",
      };
      gPostAction("/subhealth/listDatacenter", postData);
    },
    handleSet(type) {
      this.$refs.setThresholdModal.set(type.toUpperCase());
    },
  },
  watch: {
    deviceType() {
      this.loadData();
    },
  },
};
</script>

<style lang="less" scoped>
</style>
